import numpy as np
import cv2 as cv

im = np.zeros((300,300,3),np.uint8)
im[100:200,100:200] = 255
imgray = cv.cvtColor(im,cv.COLOR_BGR2GRAY)

ret, thresh = cv.threshold(imgray,127, 255 ,0)

retrievalMode = cv.RETR_TREE
approxMethod = cv.CHAIN_APPROX_NONE
contours, hierarchy = cv.findContours(thresh,retrievalMode,approxMethod)

print(contours)

img = np.zeros((300,300,3),np.uint8)
contoursIdx = 0
color,thickness = (0,0,255),1
cv.drawContours(img,contours,contoursIdx,color,thickness)

cv.imshow('im',im)
cv.imshow('img',img)
cv.waitKey(0)
cv.destroyAllWindows()
